/*
 * Class CombatList
 *
 * Version 1.0
 *
 * Created by Zach
 */

package net.com.hydroPK.world;

import net.com.hydroPK.Engine;
import net.com.hydroPK.model.Player;
import net.com.hydroPK.util.Misc;

public class ObjectList {
    /**
     * object id
     */
    public int objectId = -1;
    /**
     * object absolute x
     */
    public int absX = -1;
    /**
     * object absolute y
     */
    public int absY = -1;
    /**
     * object height
     */
    public int heightLevel = -1;
    /**
     * object face
     */
    public int face = -1;
    /**
     * object type
     */
    public int type = -1;
    /**
     * decay time
     */
    public int decayTime = -1;
    /**
     * return id
     */
    public int returnId = -1;

    public ObjectList(int object, int height, int x, int y, int face, int type, int decay, int returnid) {
        objectId = object;
        heightLevel = height;
        absX = x;
        absY = y;
        this.face = face;
        this.type = type;
        decayTime = decay;//make -1 for permanent object
        type = returnid;
    }
	

       public void createObject(Player p) {
        p.getActionSender().createObject(p, objectId, heightLevel, absX, absY, face, type);
    }
	
	

    public void clearList() {
        for (Player p : Engine.players) {
            if (p == null || p.disconnected[0]) {
                continue;
            }
            if (Misc.getDistance(p.absX, p.absY, absX, absY) < 15) {
                p.getActionSender().createObject(p, returnId, heightLevel, absX, absY, face, type);
            }
        }
        objectId = -1;
        heightLevel = -1;
        absX = -1;
        absY = -1;
        face = -1;
        type = -1;
        decayTime = -1;
        returnId = -1;
    }

    public void process() {
        if (decayTime > 0) {
            decayTime--;
        }
        if (decayTime == 0) {
            clearList();
        }
    }
}